#!/bin/sh
#
# Shell Script (Bash) to generate the Sahana PO templates
#
# Author: Ramindu Deshapriya/ Dominic
#
# Copy together with getfopts.pl into the Sahana installation path
# and execute it there, use the resulting sahana.pot for translation
#
# Requires: Perl, GNU/gettext utilities and the getfopts.pl script
#
# Generates: - temporary files "filelist.txt" and "field_options"
#            - sahana.pot

#Cache REZ database table to file - deprecated
#php -f cache_rez.inc

# Enclose .php files into the file list
find .. -name "*.php" | egrep -v "3rd/" > filelist.txt

# Enclose .inc files into the file list
find .. -name "*.inc" | egrep -v "3rd/" >> filelist.txt

# Generate field_options script from 'INSERT INTO field_options'
# This uses the getfopts.pl perl script
find .. -name "*.sql" -exec cat {} \; | perl getfopts.pl > field_options

# add the field_options script to the file list
echo ./field_options >> filelist.txt

# different xgettext calls for different contexts
xgettext -L PHP --from-code=UTF-8 --keyword=_t:1g -f filelist.txt -o locale/sahana.pot

# clean up
rm field_options filelist.txt

